package com.yixun.service.impl;

import com.yixun.entity.YxProCultured;
import com.yixun.entity.YxSurveyCanRecord;
import com.yixun.entity.YxSurveyXqRecord;
import com.yixun.mapper.YxProCulturedMapper;
import com.yixun.service.YxProCulturedService;
import org.apache.poi.hssf.usermodel.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * 畜禽种类管理(YxProCultured)表服务实现类
 *
 * @author lbx
 * @since 2021-06-16 09:00:29
 */
@Service("yxProCulturedService")
public class YxProCulturedServiceImpl implements YxProCulturedService {
    @Resource
    private YxProCulturedMapper yxProCulturedMapper;
    
    /**
     * 通过ID查询单条数据
     *
     * @param culturedId 主键
     * @return 实例对象
     */
    @Override
    public YxProCultured queryById(Long culturedId) {
        return this.yxProCulturedMapper.queryById(culturedId);
    }
    
    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<YxProCultured> queryAllByLimit(int offset, int limit) {
        return this.yxProCulturedMapper.queryAllByLimit(offset, limit);
    }
    
    /**
     * 新增数据
     *
     * @param yxProCultured 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(YxProCultured yxProCultured) {
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        yxProCultured.setAddTime(date);
        return this.yxProCulturedMapper.insert(yxProCultured);
    }
    
    /**
     * 修改数据
     *
     * @param yxProCultured 实例对象
     * @return 实例对象
     */
    @Override
    public YxProCultured update(YxProCultured yxProCultured) {
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        yxProCultured.setUpdateTime(date);
        this.yxProCulturedMapper.update(yxProCultured);
        return this.queryById(yxProCultured.getCulturedId());
    }
    
    /**
     * 通过主键删除数据
     *
     * @param culturedId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long culturedId) {
        return this.yxProCulturedMapper.deleteById(culturedId) > 0;
    }
    /**
     * 通过主键修改 is_delete
     * @param map id 主键
     * @return 受影响条数
     */
    @Override
    public int updateIsDelete(HashMap<String, Object> map) {
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        map.put("updateTime",date);
        return yxProCulturedMapper.updateIsDelete(map);
    }
    
    @Override
    public Integer getCount() {
        return    yxProCulturedMapper.getCount();
    }
    
    @Override
    public List<YxProCultured> queryAll() {
        return yxProCulturedMapper.queryAll(null);
    }
    
    @Override
    public List<YxProCultured> searchAll (HashMap<String, Object> map) {
        return yxProCulturedMapper.searchAll(map);
    }
    
    @Override
    public int getSearchCount (HashMap<String, Object> map) {
        return yxProCulturedMapper.getSearchCount(map);
    }
}
